<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
	<title>南京移动地图信息系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="shortcut icon" href="<%=basePath%>images/favicon.ico">
		<script src="<%=basePath%>jquery-easyui-1.2.6/jquery-1.7.2.min.js"
			type="text/javascript"></script>
		<script src="<%=basePath%>jquery-easyui-1.2.6/jquery.easyui.min.js"
			type="text/javascript"></script>
		<script src="<%=basePath%>js/jquery.toast.js"
			type="text/javascript"></script>
		<script type="text/javascript"
			src="<%=basePath%>jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js"></script>
		<link
			href="<%=basePath%>jquery-easyui-1.2.6/themes/default/easyui.css"
			rel="stylesheet" type="text/css" />
		<link href="<%=basePath%>jquery-easyui-1.2.6/themes/icon.css"
			rel="stylesheet" type="text/css" />
	<script type="text/javascript">
		var usersdiv;
		var channeldiv;
		var logdiv;
		var technologydiv;
		var contactdiv;
		var griddiv;
		var regiondiv;
		var operation;//0:add 1:modify
		var oldIds;
		var picPath;
		var pic_url = '<c:url context="/pic" value="/"></c:url>';
		$().ready(function() {
			$("#toRight").click(function() {
			    $("#selectLeft option:selected").each(function() {
			        $("#selectRight").append("<option value=" + $(this).val() + ">" + $(this).html() + "</option>");
			        $(this).remove();
			    });
			});

			$("#toLeft").click(function() {
			    $("#selectRight option:selected").each(function() {
			        $("#selectLeft").append("<option value=" + $(this).val() + ">" + $(this).html() + "</option>");
			        $(this).remove();
			    });
			});
			
			$("#channelTable").datagrid({loadMsg:"数据加载中,请稍后..."});
			usersdiv = document.getElementById("users");
			channeldiv = document.getElementById("channel");
			logdiv = document.getElementById("log");
			technologydiv = document.getElementById("technology");
			contactdiv = document.getElementById("contactus");
			griddiv = document.getElementById("grid");
			regiondiv = document.getElementById("region");
			reloadUserList();
			var pg_userTable = $("#userTable").datagrid("getPager");
			if (pg_userTable) {
				$(pg_userTable).pagination({
					onBeforeRefresh : function() {
					},
					onRefresh : function(pageNumber, pageSize) {
						reloadUserList();
					},
					onChangePageSize : function() {
					},
					onSelectPage : function(pageNumber, pageSize) {
						reloadUserList();
					}
				});
			}
			reloadGridsList();
			var pg_gridTable = $("#gridTable").datagrid("getPager");
			if (pg_gridTable) {
				$(pg_gridTable).pagination({
					onBeforeRefresh : function() {
					},
					onRefresh : function(pageNumber, pageSize) {
						reloadGridsList();
					},
					onChangePageSize : function() {
					},
					onSelectPage : function(pageNumber, pageSize) {
						reloadGridsList();
					}
				});
			}
			
			reloadRegionsList();
			var pg_regionTable = $("#regionTable").datagrid("getPager");
			if (pg_regionTable) {
				$(pg_regionTable).pagination({
					onBeforeRefresh : function() {
					},
					onRefresh : function(pageNumber, pageSize) {
						reloadRegionsList();
					},
					onChangePageSize : function() {
					},
					onSelectPage : function(pageNumber, pageSize) {
						reloadRegionsList();
					}
				});
			}
			
			reloadLogsList();
			$('#logTable').datagrid({
			    rowStyler:function(index,row){
			        if (row.level == 'WARN'){
			            return 'color:red';
			        }
			    }
			});
			var pg_logTable = $("#logTable").datagrid("getPager");
			if (pg_logTable) {
				$(pg_logTable).pagination({
					onBeforeRefresh : function() {
					},
					onRefresh : function(pageNumber, pageSize) {
						reloadLogsList();
					},
					onChangePageSize : function() {
					},
					onSelectPage : function(pageNumber, pageSize) {
						reloadLogsList();
					}
				});
			}
			var pg_channelTable = $("#channelTable").datagrid("getPager");
			if (pg_channelTable) {
				$(pg_channelTable).pagination({
					onBeforeRefresh : function() {
					},
					onRefresh : function(pageNumber, pageSize) {
						reloadChannelList();
					},
					onChangePageSize : function() {
					},
					onSelectPage : function(pageNumber, pageSize) {
						reloadChannelList();
					}
				});
			}
		})
		
		function reloadChannelList(){
			$.ajax({
				type : 'post',
				url : 'getChannelsList.action',
				data : 'pageNumber=' + $("#channelTable").datagrid('getPager').data("pagination").options.pageNumber+'&'+'pageSize='+$("#channelTable").datagrid('getPager').data("pagination").options.pageSize+'&'+'keyword='+$("#searchText").val(),
				async : true,
				success : function(data) {
					if(data){
						$('#channelTable').datagrid('loadData', eval(data));
					}else{
						$.toast({
							message: "查无此相关信息!",
							displayTime: 1000
						});
					}
				},
				error : function(data) {
					$.toast({
						message: "操作失败",
						displayTime: 1000
					});
				}
			});
		}
		
		function reloadLogsList(){
			$.ajax({
				type : 'post',
				url : 'getLogsList.action',
				data : 'pageNumber=' + $("#logTable").datagrid('getPager').data("pagination").options.pageNumber+'&'+'pageSize='+$("#logTable").datagrid('getPager').data("pagination").options.pageSize,
				async : true,
				success : function(data) {
					$('#logTable').datagrid('loadData', eval(data));
				},
				error : function(data) {
					$.toast({
						message: "操作失败",
						displayTime: 1000
					});

				}
			});
		}
		
		function reloadUserList(){
			$.ajax({
				type : 'post',
				url : 'getUsersList.action',
				data : 'pageNumber=' + $("#userTable").datagrid('getPager').data("pagination").options.pageNumber+'&'+'pageSize='+$("#userTable").datagrid('getPager').data("pagination").options.pageSize,
				async : true,
				success : function(data) {
					$('#userTable').datagrid('loadData', eval(data));
				},
				error : function(data) {
					$.toast({
						message: "操作失败",
						displayTime: 1000
					});

				}
			});
		}
		function showcontent(language) {
			if(language == 'channel'){
				usersdiv.style.display = "none";
				channeldiv.style.display = "block";
				reloadChannelList();
				logdiv.style.display = "none";
				technologydiv.style.display = "none";
				contactdiv.style.display = "none";
				griddiv.style.display = "none";
				regiondiv.style.display = "none";
			}else if(language == 'contact'){
				usersdiv.style.display = "none";
				channeldiv.style.display = "none";
				logdiv.style.display = "none";
				technologydiv.style.display = "none";
				contactdiv.style.display = "block";
				griddiv.style.display = "none";
				regiondiv.style.display = "none";
			}else if(language == 'log'){
				usersdiv.style.display = "none";
				channeldiv.style.display = "none";
				logdiv.style.display = "block";
				reloadLogsList();
				technologydiv.style.display = "none";
				contactdiv.style.display = "none";
				griddiv.style.display = "none";
				regiondiv.style.display = "none";
			}else if(language == 'technology'){
				usersdiv.style.display = "none";
				channeldiv.style.display = "none";
				logdiv.style.display = "none";
				technologydiv.style.display = "block";
				contactdiv.style.display = "none";
				griddiv.style.display = "none";
				regiondiv.style.display = "none";
			}else if(language == 'grid'){
				usersdiv.style.display = "none";
				channeldiv.style.display = "none";
				logdiv.style.display = "none";
				technologydiv.style.display = "none";
				contactdiv.style.display = "none";
				griddiv.style.display = "block";
				regiondiv.style.display = "none";
				reloadGridsList();
			}else if(language == 'region'){
				usersdiv.style.display = "none";
				channeldiv.style.display = "none";
				logdiv.style.display = "none";
				technologydiv.style.display = "none";
				contactdiv.style.display = "none";
				griddiv.style.display = "none";
				regiondiv.style.display = "block";
				reloadRegionsList();
			}else{
				usersdiv.style.display = "block";
				channeldiv.style.display = "none";
				logdiv.style.display = "none";
				technologydiv.style.display = "none";
				contactdiv.style.display = "none";
				griddiv.style.display = "none";
				regiondiv.style.display = "none";
			}
		}
		var url;
		function newUser() {
			operation = 0;
			$('#userdlg').dialog('open').dialog('setTitle', '新增用户');
			$('#userfm').form('clear');
			$("input:radio[name=role][value='一般用户']").attr("checked", "true");
			$('#loginName').attr("readonly",false)
		}
		function editUser() {
			operation = 1
			var row = $('#userTable').datagrid('getSelected');
			if (row) {
				$('#userdlg').dialog('open').dialog('setTitle', '查看用户');
				$('#userfm').form('load', row);
				$('#loginName').attr("readonly",true);
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		function resetPassword(){
			var row = $('#userTable').datagrid('getSelected');
			if (row) {
				$.messager.confirm('提示',
						'确定要重置密码?(密码默认为:mimr2011)',
						function(r) {
							if (r) {
								$.ajax({
									type : 'post',
									url : 'resetPassword.action',
									data : 'id=' + row.id,
									async : true,
									success : function(data) {
										$.toast({
											message: "操作成功!",
											displayTime: 1000
										});
										reloadUserList();
									},
									error : function(data) {
										$.toast({
											message: "操作失败!",
											displayTime: 1000
										});
									}
								});
							}
						});
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		function saveUser() {
			var urlstr;
			if(operation == 0){
				urlstr = 'addUser.action';
			}else{
				var row = $('#userTable').datagrid('getSelected');
				urlstr = 'addUser.action?'+'id='+row.id;
			}
			 $('#userfm').form('submit',{  
	                url: urlstr,  
	                onSubmit: function(){  
	                    return $(this).form('validate');  
	                },  
	                success: function(result){  
	                	var kkk = eval('(' + result + ')');
	                	if(kkk.result == 3){
	                		alert('该用户名已经存在!');
	                		return;
	                	}
	                	$('#userdlg').dialog('close');
	                	$.toast({
							message: "操作成功!",
							displayTime: 1000
						});
	                	reloadUserList();
	                }  
	            });  
		}
		function destroyUser() {
			var row = $('#userTable').datagrid('getSelected');
			if (row) {
				$.messager.confirm('提示',
						'确定要删除?',
						function(r) {
							if (r) {
								$.ajax({
									type : 'post',
									url : 'deleteUser.action',
									data : 'id=' + row.id,
									async : true,
									success : function(data) {
										reloadUserList();
									},
									error : function(data) {
										$.toast({
											message: "操作失败!",
											displayTime: 1000
										});
									}
								});
							}
						});
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		function newGrid(){
			operation = 0;
			$('#gridfm').form('clear');
			$('#griddlg').dialog('open');
			$('#regionGridName').attr("readonly",false);
			$("#parentRegionName").combobox({
				url : 'data/combobox_regiondata.json',
				width:'100',
				onChange : function(newValue, oldValue) {
					getGridMicroRegion(newValue);
				}
			});
		}
		
		function newRegion(){
			operation = 0;
			$('#regionfm').form('clear');
			$('#regiondlg').dialog('open').dialog('setTitle', '新增分区域');
			$('#fParentRegionName').attr("readonly",false);
			$("#fParentRegionName").combobox({
				url : 'data/combobox_regiondata.json',
				width:'100',
			});
		}
		
		function deleteRegion(){
			var row = $('#regionTable').datagrid('getSelected');
			if (row) {
				$.messager.confirm('提示',
						'确定要删除?',
						function(r) {
							if (r) {
								$.ajax({
									type : 'post',
									url : 'deleteRegion.action',
									data : 'id=' + row.id,
									async : true,
									success : function(data) {
										reloadRegionsList();
									},
									error : function(data) {
										$.toast({
											message: "操作失败!",
											displayTime: 1000
										});
									}
								});
							}
						});
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		
		function editRegion(){
			operation = 1;
			var row = $('#regionTable').datagrid('getSelected');
			if (row) {
				$('#fParentRegionName').combobox({
					url:'data/combobox_regiondata.json',
					onLoadSuccess:function(){
						$("#fParentRegionName").combobox('setValue',row.parentRegionId);
					}
				});
				$('#regiondlg').dialog('open').dialog('setTitle', '查看分区域');;
				$('#regionfm').form('load', row);
				$('#fParentRegionName').combobox('disable',true);
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		
		function saveRegion() {
			var urlstr;
			if(operation == 0){
				urlstr = 'addRegion.action?name='+encodeURI((encodeURI(fregionName.value)))+'&parentRegionId='+$("#fParentRegionName").combobox('getValue');;
			}else{
				var row = $('#regionTable').datagrid('getSelected');
				urlstr = 'editRegion.action?'+'id='+row.id+'&name='+encodeURI((encodeURI(fregionName.value)));
			}
			 $('#regionfm').form('submit',{  
	                url: urlstr,  
	                onSubmit: function(){  
	                },  
	                success: function(result){  
	                	$('#regiondlg').dialog('close');
	                	$.toast({
							message: "操作成功!",
							displayTime: 1000
						});
	                	reloadRegionsList();
	                }  
	            });  
		}
		
		function getGridMicroRegion(value){
			selectLeft.options.length = 0;  
			selectRight.options.length = 0;  
			$.ajax({
				type : 'post',
				url : 'getMicroRegionComboxJson.action?id=' + value,
				async : true,
				success : function(data) {
					reloadGridMicroRegion(data);
				},
				error : function(data) {
					$.toast({
						message: "操作失败!",
						displayTime: 1000
					});
				}
			});
		}
		
		function reloadGridMicroRegion(data){
			var obj = $("#selectLeft");
			var sHtmlTest = "";
			for(var i in data){ 
				value = data[i].id;
				name = data[i].name;
				sHtmlTest+="<option value='" + value + "'>"
				+ name 
				+ "</option>";
			}
			obj.append(sHtmlTest);
		}
		
		function saveGrid(){
			if(operation == 0){
				var itemsCount = selectRight.options.length;
				if(itemsCount == 0){
					alert("请选择微区域!")
					return;
				}
				var microRegionIds ="";
				var regionId;
				var regionName;
				var name;
				for(var i=0;i<itemsCount-1;i++){
					microRegionIds +=selectRight.options[i].value+",";
				}
				microRegionIds+=selectRight.options[i].value;
				regionId = $("#parentRegionName").combobox('getValue');
				regionName = $("#parentRegionName").combobox('getText');
				name = regionGridName.value;
				
				$.ajax({
					type : 'post',
					url : 'addGrid.action?name=' + encodeURI((encodeURI(name)))+'&'+'regionId='+regionId+'&'+'regionName='+encodeURI((encodeURI(regionName)))+'&'+'microRegionIds='+microRegionIds,
					async : true,
					success : function(data) {
						$('#griddlg').dialog('close');
						$.toast({
							message: "操作成功!",
							displayTime: 1000
						});
						reloadGridsList();
					},
					error : function(data) {
						$.toast({
							message: "操作失败!",
							displayTime: 1000
						});
					}
				});
			}else{
				var row = $('#gridTable').datagrid('getSelected');
				var newIds = "";
				var itemsCount = selectRight.options.length;
				for(var i=0;i<itemsCount-1;i++){
					newIds +=selectRight.options[i].value+",";
				}
				newIds+=selectRight.options[i].value;
				$.ajax({
					type : 'post',
					url : 'editGrid.action?id='+row.id+'&'+'oldIds='+oldIds+'&'+'newIds='+newIds,
					async : true,
					success : function(data) {
						$('#griddlg').dialog('close');
						$.toast({
							message: "操作成功!",
							displayTime: 1000
						});
						reloadGridsList();
					},
					error : function(data) {
						$.toast({
							message: "操作失败!",
							displayTime: 1000
						});
					}
				});
			}
		}
		
		function editGrid(){
			$('#gridfm').form('clear');
			selectLeft.options.length = 0;  
			selectRight.options.length = 0;  
			operation = 1;
			var row = $('#gridTable').datagrid('getSelected');
			if (row) {
				$('#parentRegionName').combobox({
					url:'data/combobox_regiondata.json',
					onLoadSuccess:function(){
						$("#parentRegionName").combobox('setValue',row.parentRegionId);
					}
				});
				$('#griddlg').dialog('open');
				$('#gridfm').form('load', row);
				$('#regionGridName').attr("readonly",true);
				//$('#parentRegionName').attr("readonly",true);
				$("#parentRegionName").combobox('disable',true);
				$.ajax({
					type : 'post',
					url : 'getGridInfo.action?id='+row.id+'&'+'regionId='+row.parentRegionId,
					async : true,
					success : function(data) {
						var leftobj = $("#selectLeft");
						var rightobj = $("#selectRight");
						var sHtmlTest = "";
						oldIds = "";
						var json1 = data[0].split(";");
						for(var j=0; j<json1.length; j++){
							var regionvail = json1[j].split(",");
							sHtmlTest+="<option value='" + regionvail[0] + "'>"
							+ regionvail[1] 
							+ "</option>";
							oldIds+=regionvail[0]+','
						}
						oldIds.substring(0, oldIds.length-1);
						rightobj.append(sHtmlTest);
						sHtmlTest = "";
						var json2 = data[1].split(";");
						for(var j=0; j<json2.length; j++){
							var regionvail = json2[j].split(",");
							sHtmlTest+="<option value='" + regionvail[0] + "'>"
							+ regionvail[1] 
							+ "</option>";
						}
						leftobj.append(sHtmlTest);
					},
					error : function(data) {
						$.toast({
							message: "操作失败!",
							displayTime: 1000
						});
					}
				});
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		
		function deleteGrid(){
			var row = $('#gridTable').datagrid('getSelected');
			if (row) {
				$.messager.confirm('提示',
						'确定要删除?',
						function(r) {
							if (r) {
								$.ajax({
									type : 'post',
									url : 'deleteGrid.action',
									data : 'id=' + row.id,
									async : true,
									success : function(data) {
										reloadGridsList();
									},
									error : function(data) {
										$.toast({
											message: "操作失败!",
											displayTime: 1000
										});
									}
								});
							}
						});
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		
		function reloadGridsList(){
			$.ajax({
				type : 'post',
				url : 'getGridsList.action',
				data : 'pageNumber=' + $("#gridTable").datagrid('getPager').data("pagination").options.pageNumber+'&'+'pageSize='+$("#gridTable").datagrid('getPager').data("pagination").options.pageSize,
				async : true,
				success : function(data) {
					$('#gridTable').datagrid('loadData', eval(data));
				},
				error : function(data) {
					$.toast({
						message: "操作失败",
						displayTime: 1000
					});

				}
			});
		}
		
		function reloadRegionsList(){
			$.ajax({
				type : 'post',
				url : 'getRegionsList.action',
				data : 'pageNumber=' + $("#regionTable").datagrid('getPager').data("pagination").options.pageNumber+'&'+'pageSize='+$("#regionTable").datagrid('getPager').data("pagination").options.pageSize,
				async : true,
				success : function(data) {
					$('#regionTable').datagrid('loadData', eval(data));
				},
				error : function(data) {
					$.toast({
						message: "操作失败",
						displayTime: 1000
					});

				}
			});
		}
		
		function newChannel(){
			operation = 0;
			$('#channeldlg').dialog('open');
			$('#regionName').combobox({url:'data/combobox_regiondata.json',width:'120'});
			$('#networkType').combobox({url:'data/combobox_channeltypedata.json',width:'120'});
			$('#channelfm').form('clear');
		}
		function editChannel(){
			operation = 1;
			var row = $('#channelTable').datagrid('getSelected');
			if (row) {
				$('#channeldlg').dialog('open');
				$('#regionName1').combobox({url:'data/combobox_regiondata.json'});
				$('#networkType1').combobox({url:'data/combobox_channeltypedata.json'});
				$('#channelfm').form('load', row);
				this.picPath = row.pic_Url;
            	document.getElementById("showimg").src= pic_url+this.picPath;
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		function saveChannel(){
			var urlstr;
			if(operation == 0){
				urlstr = 'addChannel.action?'+'pic_Url='+this.picPath;
			}else{
				var row = $('#channelTable').datagrid('getSelected');
				urlstr = 'addChannel.action?'+'id='+row.id+'&'+'pic_Url='+this.picPath;
			}
			$('#channelfm').form('submit',{  
                url: urlstr,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                	var kkk = eval('('+result+')');
                	if(kkk.result == 1){
                		$('#channeldlg').dialog('close');
                    	$.toast({
    						message: "操作成功!",
    						displayTime: 1000
    					});
                    	reloadChannelList();
                	}else{
                		$.toast({
    						message: "操作失败!",
    						displayTime: 1000
    					});
                	}
                }  
            });  
		}
		function destroyChannel(){
			var row = $('#channelTable').datagrid('getSelected');
			if (row) {
				$.messager.confirm('提示',
						'确定要删除?',
						function(r) {
							if (r) {
								$.ajax({
									type : 'post',
									url : 'deleteChannel.action',
									data : 'id=' + row.id,
									async : true,
									success : function(data) {
										reloadChannelList();
									},
									error : function(data) {
										$.toast({
											message: "操作失败!",
											displayTime: 1000
										});
									}
								});
							}
						});
			}else{
				$.toast({
					message: "请选择一条数据!",
					displayTime: 1000
				});
			}
		}
		
		function importChannel(){
			$('#uploaddlg').dialog('open').dialog('setTitle', '数据导入');;
		}
		
		function exportChannel(){
			$.ajax({
				type : 'post',
				url : 'exportExcel.action',
				async : true,
				success : function(data) {
				},
				error : function(data) {
					$.toast({
						message: "操作失败",
						displayTime: 1000
					});

				}
			});
		}
		
		function deleteAll(){
			$.messager.confirm('提示',
					'确定要删除全部网点数据?',
					function(r) {
						if (r) {
							$.ajax({
								type : 'post',
								url : 'deleteAllChannels.action',
								async : true,
								success : function(data) {
									var kl = eval('(' + data + ')');
									if(kkk.result == '1'){
										$.toast({
											message: "操作成功!",
											displayTime: 1000
										});
									}else{
										$.toast({
											message: "操作失败!",
											displayTime: 1000
										});
									}
								},
								error : function(data) {
									$.toast({
										message: "操作失败!",
										displayTime: 1000
									});
								}
							});
						}
					});
		}
		
		function getLogByDate(){
			var selectedDate= $('#logDate').datebox('getValue');
			if(selectedDate+"" == "undefined" ||selectedDate == ""){
				$.toast({
					message: "请选择日期",
					displayTime: 1000
				});
				return ;
			}else{
				 document.forms[0].action="downloadLog.action?selectedDate="+selectedDate; 
				 document.forms[0].submit(); 
			}
		}
		function searchByKeyword(){
			if($("#searchText").val() == ""){
				$.toast({
					message: "请输入要查询内容!",
					displayTime: 1000
				});
				return;
			}
			reloadChannelList();
		}
		function changePassword(){
			$('#changePassworddlg').dialog('open').dialog('setTitle', '修改密码');
			$('#passwordfm').form('clear');
		}
		function saveNewPassword(){
			if($("#oldPassword").val()=='' ||$("#newPassword").val()==''||$("#newPassword1").val()==''){
				alert('请填写完整信息');
				return;
			}
			if($("input[name='newPassword']").val()!=$("input[name='newPassword1']").val()){
				alert('两次密码不一样！');
				return
			}
			$.ajax({
				type : 'post',
				url : 'changePassword.action',
				data : 'oldPassword='+$("#oldPassword").val()+'&'+'newPassword='+$("#newPassword").val(),
				async : true,
				success : function(data) {
					var kkk = eval('('+data+')');
					if(kkk.result == 3){
						alert('原密码错误');
						return;
					}
					$('#changePassworddlg').dialog('close');
					$.toast({
						message: "修改成功!",
						displayTime: 1000
					});
				},
				error : function(data) {
					alert('操作失败!');
				}
			});
		}
		function uploadXls(){
			if($('#file').val() == ""){
				alert("请选择xls文件!");
				return;
			}
			var   last= $('#file').val().match(/^(.*)(\.)(.{1,8})$/)[3]; 
	        last=last.toUpperCase();
	        if(last != "XLS"){
	        	alert("请选择xls文件!");
				return;
	        }
			$('#uploadfm').form('submit',{  
                success: function(result){  
                	$('#uploaddlg').dialog('close');
                	$.toast({
						message: "上传成功!",
						displayTime: 1000
					});
                }  
            });  
		}
		
		function uploadPic(){
			if($('#pic').val() == ""){
				alert("请选择图片!");
				return;
			}
			var   last= $('#pic').val().match(/^(.*)(\.)(.{1,8})$/)[3]; 
	        last=last.toUpperCase();
	        if(last != "JPG" && last != "JPEG" && last != "BMP" && last != "GIF"){
	        	alert("请选择图片文件格式!");
				return;
	        }
			$('#picfm').form('submit',{  
                success: function(result){ 
                	var k = eval('(' + result + ')');
                	picPath = k.name;
                	document.getElementById("showimg").src= pic_url+picPath;
                }  
            });
		}
		
		function resetPic(){
			document.getElementById("showimg").src=pic_url+"hi.jpg";
			this.picPath = "";
		}
	</script>
	<style>
		a:link { text-decoration: none;color: blue}
		a:visited {color: blue}  
		a:hover {color: blue}    
		a:active {color: blue} 
		.panel-body{
			background:#f0f0f0;
		}
		.panel-header{
			background:#fff url('images/panel_header_bg.gif') no-repeat top right;
		}
		.panel-tool-collapse{
			background:url('images/arrow_up.gif') no-repeat 0px -3px;
		}
		.panel-tool-expand{
			background:url('images/arrow_down.gif') no-repeat 0px -3px;
		}
		 #fm{  
            margin:0;  
            padding:10px 30px;  
        }  
        .ftitle{  
            font-size:14px;  
            font-weight:bold;  
            color:#666;  
            padding:5px 0;  
            margin-bottom:10px;  
            border-bottom:1px solid #ccc;  
        }  
        .fitem{  
            margin-bottom:5px;  
        }  
        .fitem label{  
            display:inline-block;  
            width:80px;  
        } 
        .toast{
		/* border properties */
		border-radius: 4px;
		-moz-border-radius: 4px;
		-webkit-border-radius: 4px;
		border: 2px solid #CCCCCC;
 
		/* Aesthetics */
		position: absolute;
		padding: 10px;
		color: #ffffff;
		background-color:rgba(0,0,0, 0.8);
		display:none;}
	</style>
</head>
<body>
	<body class="easyui-layout">  
      <div region="north" style="height:83px;">
	 <div id="header" style="height:80px;margin:0;padding:0;border-bottom:1px solid #d5ddf3;background-color:rgb(206,206,206);clear:both">
		<div id="logo" style="font-size:2em;float:left">
			<img src="images/banner.jpg"/>
		</div>
		<div id="sys_menu" style="padding-left:10px;padding-right:10px;color:#000000;background-color:rgb(206,206,206);float:right;height:29px;padding-top:5px;color:#0000FF;text-decoration:none;margin-top:10px;">
				您好, ${session.username}， <a
					href="/MobileMaps/index.jsp"> 首页</a> | <a
					href="javascript:changePassword();"> 修改密码</a> |
					<a href="/MobileMaps/admin.jsp">系统管理</a>|
				<a href="logout.action">退出</a>
		</div>
	  </div>
	  </div>  
      <div region="south"  style="height:50px;margin:2px 7px 20px 7px;display:block;text-align:center;clear:both">&copy; 2011,2012 Getsea Team. All Rights Reserved.</div>  
      <div region="west" style="width:215px;overflow-x: hidden; overflow-y: hidden;"><div style="width:100%;height:100%;background-color:rgb(206,206,206);padding:5px;">
		<div class="easyui-panel" title="参数管理" collapsible="true" style="width:200px;height:auto;padding:10px;">
				<li><a href="javascript:void(0)" onclick="showcontent('users')">用户管理</a></li>
				<br/>
				<li><a href="javascript:void(0)" onclick="showcontent('channel')">渠道网点管理</a></li>
				<br/>
				<li><a href="javascript:void(0)" onclick="showcontent('grid')">网格管理</a></li>
				<br/>
				<li><a href="javascript:void(0)" onclick="showcontent('region')">分区域管理</a></li>
				</ul>
			<br/>
		</div>
		<div class="easyui-panel" title="内部维护" collapsible="true" style="width:200px;height:auto;padding:10px;">
		        <li><a href="javascript:void(0)" onclick="showcontent('log')">日志管理</a></li>
				<br/>
				<li><a href="javascript:void(0)" onclick="showcontent('technology')">技术日志</a></li>
				</ul>
			<br/>
		</div>
		<div class="easyui-panel" title="协助" collapsible="true" style="width:200px;height:auto;padding:10px;">
			<li><a href="javascript:void(0)" onclick="showcontent('contact')">联系我们</a></li>
				</ul><br/>
		</div>
		<br/>
	</div></div>  
      <div region="center" id="content"  style="padding:5px;">
      <div  class="content" id="grid" style="display:none;">
	  <h2>网格管理</h2><hr>
		<table id="gridTable"  title="网格列表" class="easyui-datagrid" 
            toolbar="#gridtoolbar" pagination="true"  idField="id",
            rownumbers="true" fitColumns="true" singleSelect="true">  
        <thead>  
            <tr>  
                <th field="name" align="center" width="150">网格名称</th>  
                <th field="parentRegionName" align="center" width="200">所属区域</th>  
            </tr>  
        </thead>  
    </table>  
    <div id="gridtoolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newGrid()">新增网格</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onClick="editGrid()"">查看网格</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onClick="deleteGrid()">删除网格</a>  
    </div>  
      
    <div id="griddlg" class="easyui-dialog" style="width:500px;height:400px;padding:10px 20px"  
            closed="true" buttons="#griddlg-buttons">  
        <div class="ftitle">网格信息</div>  
        <form id="gridfm" method="post" novalidate>  
            <div class="fitem">  
                <label>网格名称:</label>  
                <input name="name" id="regionGridName" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>所属区域:</label>  
                <input name="parentRegionName" class="easyui-validatebox" valueField="id" textField="text" id="parentRegionName"  required="true">  
            </div>  
            <div class="fitem">
						<table>
							<tr>
								<td><select size='11' multiple id="selectLeft"
									style="width: 200px">
								</select></td>
								<td><input type="button" value=" >> " id="toRight" /><br />
								<br /> <input type="button" value=" << " id="toLeft" /></td>
								<td><select size='11' multiple id="selectRight"
									style="width: 200px">
								</select></td>
							</tr>
						</table>
					</div>  
        </form>  
    </div>  
    <div id="griddlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveGrid()">保存</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#griddlg').dialog('close')">取消</a>  
    </div>  
    </div>
    <div  class="content" id="region" style="display:none;">
	  <h2>分区域管理</h2><hr>
		<table id="regionTable"  title="分区域列表" class="easyui-datagrid" 
            toolbar="#regiontoolbar" pagination="true"  idField="id",
            rownumbers="true" fitColumns="true" singleSelect="true">  
        <thead>  
            <tr>  
                <th field="name" align="center" width="150">分区域名称</th>  
                <th field="parentRegionName" align="center" width="200">所属区域</th>  
            </tr>  
        </thead>  
    </table>  
    <div id="regiontoolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newRegion()">新增分区域</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onClick="editRegion()">查看分区域</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onClick="deleteRegion()">删除分区域</a>  
    </div>  
      
    <div id="regiondlg" class="easyui-dialog" style="width:300px;height:200px;padding:10px 20px"  
            closed="true" buttons="#regiondlg-buttons">  
        <div class="ftitle">分区域信息</div>  
        <form id="regionfm" method="post" novalidate>  
            <div class="fitem">  
                <label>分区域名称:</label>  
                <input name="name" id="fregionName" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>所属区域:</label>  
                <input name="fParentRegionName" class="easyui-validatebox" valueField="id" textField="text" id="fParentRegionName"  required="true">  
            </div>  
        </form>  
    </div>  
    <div id="regiondlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveRegion()">保存</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#regiondlg').dialog('close')">取消</a>  
    </div>  
    </div>
      <div class="content" id="log" style="display:none;">
       <h2> 日志管理 </h2> <hr>
       <table id="logTable"  title="日志列表" class="easyui-datagrid" 
            pagination="true"  idField="id",
            rownumbers="true" fitColumns="true" singleSelect="true">  
        <thead>  
            <tr>  
                <th field="loginName" align="center" width="80">登录号</th>  
                <th field="remoteAddress" align="center" width="150">访问地址</th>  
                <th field="message" align="center" width="300">消息内容</th>  
                <th field="createdAt" align="center" width="200">记录时间</th>  
            </tr>  
        </thead>  
        </table>
      </div>
      <div class="content" id="technology" style="display:none;">
       <h2>技术日志 </h2> <hr>
       <div  style="padding: 10px;">
       	日志日期
       <input id="logDate" type="text" class="easyui-datebox"  ></input>  
       <a href="javascript:void(0)" onclick="getLogByDate()" class="easyui-linkbutton" iconCls="icon-save">获取</a> 
       </div>
      </div>
	  <div class="content" id="contactus" style="display:none;" >
	  <h2>  联系我们 </h2> <hr>
	  <p> <strong>联系电话：</strong>13851823105</p> 
	  <p> <strong>电子邮件：</strong><a href="mailto:81753336@qq.com">81753336@qq.com</a> </p> 
	  <p> <strong>QQ：</strong>81753336</p>
	  </div>
	  <div  class="content" id="users" >
	  <h2>用户管理</h2><hr>
		<table id="userTable"  title="用户列表" class="easyui-datagrid" 
            toolbar="#usertoolbar" pagination="true"  idField="id",
            rownumbers="true" fitColumns="true" singleSelect="true">  
        <thead>  
            <tr>  
                <th field="loginName" align="center" width="80">登录名</th>  
                <th field="fullName" align="center" width="80">姓名</th>  
                <th field="role" align="center" width="80">角色</th>  
            </tr>  
        </thead>  
    </table>  
    <div id="usertoolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">新增用户</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">查看用户</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除用户</a>  
    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" plain="true" onclick="resetPassword()">重置密码</a> 
    </div>  
      
    <div id="userdlg" class="easyui-dialog" style="width:350px;height:260px;padding:10px 20px"  
            closed="true" buttons="#userdlg-buttons">  
        <div class="ftitle">用户信息</div>  
        <form id="userfm" method="post" novalidate>  
            <div class="fitem">  
                <label>登录号:</label>  
                <input name="loginName" id="loginName" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>姓名:</label>  
                <input name="fullName" class="easyui-validatebox" required="true">  
            </div>  
            <div class="fitem">  
                <label>角色:</label>  
                <input name="role" type="radio" value="一般用户" checked="true"/>一般用户
				<input name="role" type="radio" value="系统管理员"/>系统管理员
            </div>  
            <div>
            <label><h2>初始密码为mimr2011</h2></label>
            </div>
        </form>  
    </div>  
    <div id="userdlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">保存</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#userdlg').dialog('close')">取消</a>  
    </div>  
	  </p>
	  </div>
	  <div  class="content" id="channel" style="display:none;">
		<h2>渠道网点管理</h2><hr>
    	 <table id="channelTable"  title="渠道网点列表" class="easyui-datagrid" 
            toolbar="#channeltoolbar" pagination="true"  idField="id",
            rownumbers="true" fitColumns="true" singleSelect="true">  
        <thead>  
            <tr>  
                <th field="regionName" align="center" width="80">网点区域</th>  
                <th field="networkType" align="center" width="80">网点类型</th>  
                <th field="channelCode" align="center" width="80">渠道代码</th>
				<th field="name" align="center" width="300">网点名称</th>  
				<th field="address" align="center" width="300">地址</th>   
            </tr>  
        </thead>  
    </table>  
    <div id="channeltoolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newChannel()">新增</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editChannel()">查看</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyChannel()">删除</a>  
    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" plain="true" onclick="importChannel()">导入</a> 
    	<a href="exportExcel.action" class="easyui-linkbutton" iconCls="icon-redo" plain="true" >导出全部</a> 
    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" plain="true" color='red' onclick="deleteAll()">删除全部</a> 
    	关键字查询:<input id="searchText" class="easyui-validatebox" style="width:100px">  
            <a href="#" class="easyui-linkbutton" onclick="searchByKeyword()" iconCls="icon-search">查询</a> 
         </div> 
    </div>  
	  </div>
	</div> 
	<div id="changePassworddlg" class="easyui-dialog" style="width:330px;height:250px;padding:10px 20px"  
            closed="true" buttons="#changePassworddlg-buttons">  
        <div class="ftitle">修改密码</div>  
        <form id="passwordfm" method="post" novalidate>  
            <div class="fitem">  
                <label>旧密码:</label>  
                <input id="oldPassword" name="oldPassword" class="easyui-validatebox" type="password">  
            </div>  
            <div class="fitem">  
                <label>新密码:</label>  
                <input id="newPassword" name="newPassword" class="easyui-validatebox" type="password">  
            </div>  
            <div class="fitem">  
                <label>重复新密码:</label>
                <input id="newPassword1" name="newPassword1" class="easyui-validatebox" type="password">  
            </div>  
        </form>  
    </div>  
    <div id="changePassworddlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveNewPassword()">确定</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#changePassworddlg').dialog('close')">取消</a>  
    </div>
    <div id="channeldlg" class="easyui-dialog" title="网点信息" style="width:560px;height:560px;" buttons="#channeldlg-buttons"  closed="true">
		<div selected="true" style="padding:20px 20px 20px 20px;">
			<form id="channelfm" method="post">
				<table>
					<tr>
						<div class="fitem">
						<td>序号：</td>
						<td><input id="sn" name="sn" required="true"></input></td>
						</div>
						<td>网点区域：</td>
						<td><input width="100px" valueField="text" textField="text" id="regionName" name="regionName"></input></td>
					</tr>
					<tr>
						<div class="fitem">  
						<td>区域属性：</td>
						<td><input id="regionProperty" name="regionProperty"></input></td>
						</div>
						<div class="fitem">  
						<td>渠道代码：</td>
						<td><input id="channelCode" name="channelCode"></input></td>
						</div>
					</tr>
					<tr>
						<div class="fitem">  
						<td>营销单元：</td>
						<td><input id="maketingUnit" name="maketingUnit"></input></td>
						</div>
						<div class="fitem">  
						<td>微区域：</td>
						<td><input id="microRegion" name="microRegion"></input></td>
						</div>
					</tr>
					<tr>
						<div class="fitem">  
						<td>营业厅/渠道：</td>
						<td><input id="channelType" name="channelType"></input></td>
						</div>
						<td>网点类型：</td>
						<td><input width="100px"  valueField="text" textField="text" id="networkType" name="networkType"></input></td>
					</tr>
					<tr>
						<div class="fitem">  
						<td>网点名称：</td>
						<td><input id="name" name="name"></input></td>
						</div>
						<div class="fitem">  
						<td>外包情况：</td>
						<td><input id="outsourcing" name="outsourcing"></input></td>
						</div>
					</tr>
					<tr>
						<div class="fitem">  
						<td>地址：</td>
						<td><input id="address" name="address"></input></td>
						</div>
						<div class="fitem">  
						<td>店长/渠道经理：</td>
						<td><input id="manager" name="manager"></input></td>
						</div>
					</tr>
					<tr>
						<div class="fitem">  
						<td>联系电话：</td>
						<td><input id="phone" name="phone" ></input></td>
						</div>
						<div class="fitem">  
						<td>网点性质：</td>
						<td><input id="specialty" name="specialty"></input></td>
						</div>
					</tr>
					<tr>
						<div class="fitem">  
						<td>区域环境：</td>
						<td><input id="regionEnvironment" name="regionEnvironment"></input></td>
						</div>
						<div class="fitem">  
						<td>网点面积：</td>
						<td><input id="area" name="area"></input></td>
						</div>
					</tr>
					<tr>
						<div class="fitem">  
						<td>网点经度：</td>
						<td><input id="longitude"   name="longitude" ></input></td>
						</div>
						<div class="fitem">  
						<td>网点维度：</td>
						<td><input id="latitude"  name="latitude"></input></td>
						</div>
					</tr>
				</table>
			</form>
			<form id="picfm" action="uploadPic" method="post" enctype="multipart/form-data" novalidate>
			<div>
			<img id="showimg"  style="width:160px;height:120px;"/> 
			</div>
			<div>
			<input type="file" name="pic" id="pic" onchange="uploadPic()">
			</div>
			<div>
			<input type="reset" value="重置" onclick="resetPic()">  
			</div>
			</form>
			</div>
		</div>
		<div id="channeldlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveChannel()">保存</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#channeldlg').dialog('close')" >取消</a>  
    	</div>
    	<div id="uploaddlg" class="easyui-dialog" style="width:330px;height:200px;padding:10px 20px"  
            closed="true" buttons="#uploaddlg-buttons">  
        <form id="uploadfm" action="upload" method="post" enctype="multipart/form-data" novalidate>  
        	<a href="<c:url value="/resources/templates/template.xls"/>"><h2> 导出下载模板 </h2> <hr></a>
            <input type="file" name="fileName" id="file" size="60">
        </form>  
    </div> 
    <div id="uploaddlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="uploadXls()">导入</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#uploaddlg').dialog('close')" >取消</a>  
    	</div>
 </body>  
</body>
</html>